import os

learner="/home/passwd123/XiaoweiGuo/vscode/code-security/third_party/JaSt/clustering/learner.py"
updater="/home/passwd123/XiaoweiGuo/vscode/code-security/third_party/JaSt/clustering/updater.py"
classifier="/home/passwd123/XiaoweiGuo/vscode/code-security/third_party/JaSt/clustering/classifier.py"

def train(good_dir,bad_dir,model_file):
    model_dir=os.path.dirname(model_file)
    model_file=os.path.basename(model_file)
    cmd=f'python {learner} --d {good_dir} {bad_dir} --l benign malicious --mn {model_file} --md {model_dir}'
    
    return os.system(cmd)

def update(model_file,good_dir,bad_dir,new_model_file=None):
    if new_model_file is None:
        cmd=f'python {updater} --d {good_dir} {bad_dir} --m {model_file}'
    else:
        new_model_dir=os.path.dirname(new_model_file)
        new_model_name=os.path.basename(new_model_file)
        cmd=f'python {updater} --d {good_dir} {bad_dir} --m {model_file} --mn {new_model_name} --md {new_model_dir}'
    return os.system(cmd)

def classify(model_file,good_dir,bad_dir):
    cmd=f'python {classifier} --d {good_dir} {bad_dir} --m {model_file}'
    return os.system(cmd)